package com.jzo2o.orders.manager.Client;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
//import com.jzo2o.api.customer.AddressBookApi;
//import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import com.jzo2o.api.customer.AddressBookApi;
import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ Tool：IntelliJ IDEA
 * @ Author：徐茂茂
 * @ Date：2025-10-13-1:32
 * @ Version：1.0
 * @ Description：
 */
@Component
@Slf4j
public class CustomerClient {


    @Resource
    private AddressBookApi addressBookApi;

    @SentinelResource(value = "getAddressBookDetail",
            fallback ="detailFallback" ,
            blockHandler ="detailBlockHandler" )
    public AddressBookResDTO getDetail(Long id){
        return addressBookApi.detail(id);
    }

    /***
     * 根据ID查询地址簿【降级处理方法】
     */
    public AddressBookResDTO detailFallback(Long id,
                                            Throwable throwable){
        log.error("普通降级处理，id=:{}，异常信息：{}",id,throwable);
        return null;
    }
    /***
     * 根据ID查询地址簿【熔断处理方法】
     */
    public AddressBookResDTO detailBlockHandler(Long id,
                                                BlockException blockException){
        log.error("熔断降级处理，id=:{}，异常信息：{}",id,blockException);
        return null;
    }

}
